<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title }}</title>
    <link rel="stylesheet" href="{{ css_path|default('style.css') }}">
</head>
<body>
    <div class="container">
        <header>
            <h1>应用程序框架分析报告</h1>
            <p>分析时间: {{ result.analysis_time.strftime('%Y-%m-%d %H:%M:%S') }}</p>
        </header>
        
        <section class="app-info">
            <h2>应用信息</h2>
            <table>
                <tr>
                    <th>应用名称</th>
                    <td>{{ result.app_name or '未知' }}</td>
                </tr>
                <tr>
                    <th>应用版本</th>
                    <td>{{ result.app_version or '未知' }}</td>
                </tr>
                <tr>
                    <th>平台</th>
                    <td>{{ result.platform }}</td>
                </tr>
                <tr>
                    <th>应用路径</th>
                    <td>{{ result.app_path }}</td>
                </tr>
            </table>
        </section>
        
        <h2>识别到的框架</h2>
        {% if result.frameworks %}
            {% if result.get_main_frameworks() %}
                <div class="main-framework-section">
                    <h3>主要框架</h3>
                    {% for framework in result.get_main_frameworks() %}
                        <div class="framework main-framework">
                            <h3>{{ framework.name }} {% if framework.version %}{{ framework.version }}{% endif %}</h3>
                            <div class="confidence">
                                {% set width_pct = framework.confidence * 100 %}
                                <div class="confidence-bar" style="width: {{ width_pct }}%;">
                                    {{ "%.0f"|format(width_pct) }}%
                                </div>
                            </div>
                            
                            <h4>类别:</h4>
                            <p>{{ framework.category }}</p>
                            
                            <h4>特征:</h4>
                            {% if framework.features %}
                                <ul>
                                    {% for feature in framework.features %}
                                        <li>{{ feature }}</li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <p>未发现特征。</p>
                            {% endif %}
                            
                            <h4>相关文件:</h4>
                            {% if framework.files %}
                                <ul>
                                    {% for file in framework.files %}
                                        <li>{{ file }}</li>
                                    {% endfor %}
                                </ul>
                            {% else %}
                                <p>未发现相关文件。</p>
                            {% endif %}
                            
                            {% if framework.related_frameworks %}
                                <h4>相关框架:</h4>
                                <ul class="related-frameworks">
                                    {% for related in framework.related_frameworks %}
                                        <li>{{ related }}</li>
                                    {% endfor %}
                                </ul>
                            {% endif %}
                        </div>
                    {% endfor %}
                </div>
            {% endif %}
            
            <h3>所有检测到的框架</h3>
            {% if result.get_frameworks_by_category().keys()|length > 1 %}
                <div class="framework-categories">
                    <div class="tabs">
                        {% for category in result.get_frameworks_by_category().keys() %}
                            <div class="tab" onclick="showCategory('{{ category }}')">{{ category }}</div>
                        {% endfor %}
                    </div>
                    
                    {% for category, frameworks in result.get_frameworks_by_category().items() %}
                        <div id="category-{{ category|replace(' ', '-') }}" class="category-content">
                            <h3>{{ category }}</h3>
                            {% for framework in frameworks %}
                                <div class="framework">
                                    <h3>{{ framework.name }} {% if framework.version %}{{ framework.version }}{% endif %}</h3>
                                    <div class="confidence">
                                        {% set width_pct = framework.confidence * 100 %}
                                        <div class="confidence-bar" style="width: {{ width_pct }}%;">
                                            {{ "%.0f"|format(width_pct) }}%
                                        </div>
                                    </div>
                                    
                                    <h4>特征:</h4>
                                    {% if framework.features %}
                                        <ul>
                                            {% for feature in framework.features %}
                                                <li>{{ feature }}</li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        <p>未发现特征。</p>
                                    {% endif %}
                                    
                                    <h4>相关文件:</h4>
                                    {% if framework.files %}
                                        <ul>
                                            {% for file in framework.files %}
                                                <li>{{ file }}</li>
                                            {% endfor %}
                                        </ul>
                                    {% else %}
                                        <p>未发现相关文件。</p>
                                    {% endif %}
                                    
                                    {% if framework.related_frameworks %}
                                        <h4>相关框架:</h4>
                                        <ul class="related-frameworks">
                                            {% for related in framework.related_frameworks %}
                                                <li>{{ related }}</li>
                                            {% endfor %}
                                        </ul>
                                    {% endif %}
                                </div>
                            {% endfor %}
                        </div>
                    {% endfor %}
                </div>
            {% else %}
                {% for framework in result.frameworks %}
                    <div class="framework">
                        <h3>{{ framework.name }} {% if framework.version %}{{ framework.version }}{% endif %}</h3>
                        <div class="confidence">
                            {% set width_pct = framework.confidence * 100 %}
                            <div class="confidence-bar" style="width: {{ width_pct }}%;">
                                {{ "%.0f"|format(width_pct) }}%
                            </div>
                        </div>
                        
                        <h4>类别:</h4>
                        <p>{{ framework.category }}</p>
                        
                        <h4>特征:</h4>
                        {% if framework.features %}
                            <ul>
                                {% for feature in framework.features %}
                                    <li>{{ feature }}</li>
                                {% endfor %}
                            </ul>
                        {% else %}
                            <p>未发现特征。</p>
                        {% endif %}
                        
                        <h4>相关文件:</h4>
                        {% if framework.files %}
                            <ul>
                                {% for file in framework.files %}
                                    <li>{{ file }}</li>
                                {% endfor %}
                            </ul>
                        {% else %}
                            <p>未发现相关文件。</p>
                        {% endif %}
                        
                        {% if framework.related_frameworks %}
                            <h4>相关框架:</h4>
                            <ul class="related-frameworks">
                                {% for related in framework.related_frameworks %}
                                    <li>{{ related }}</li>
                                {% endfor %}
                            </ul>
                        {% endif %}
                    </div>
                {% endfor %}
            {% endif %}
        {% else %}
            <div class="framework">
                <p>未识别到任何框架。</p>
            </div>
        {% endif %}
        
        {% if result.metadata %}
            <h2>附加信息</h2>
            <div class="framework">
                <table>
                    {% for key, value in result.metadata.items() %}
                        <tr>
                            <th>{{ key }}</th>
                            <td>{{ value }}</td>
                        </tr>
                    {% endfor %}
                </table>
            </div>
        {% endif %}
        
        <footer>
            <p>应用程序框架分析器 - 报告生成时间: {{ generated_time }}</p>
        </footer>
    </div>
    
    <script>
        // 类别切换功能
        function showCategory(category) {
            // 隐藏所有类别内容
            const allCategories = document.querySelectorAll('.category-content');
            allCategories.forEach(cat => {
                cat.classList.remove('active');
            });
            
            // 移除所有标签的活跃状态
            const allTabs = document.querySelectorAll('.tab');
            allTabs.forEach(tab => {
                tab.classList.remove('active');
            });
            
            // 显示选定的类别
            const selectedCategory = document.getElementById('category-' + category.replace(' ', '-'));
            if (selectedCategory) {
                selectedCategory.classList.add('active');
            }
            
            // 设置选定标签的活跃状态
            const tabs = document.querySelectorAll('.tab');
            tabs.forEach(tab => {
                if (tab.innerText === category) {
                    tab.classList.add('active');
                }
            });
        }
        
        // 初始化页面时显示第一个类别
        document.addEventListener('DOMContentLoaded', function() {
            const categories = document.querySelectorAll('.category-content');
            const tabs = document.querySelectorAll('.tab');
            
            if (categories.length > 0) {
                categories[0].classList.add('active');
            }
            
            if (tabs.length > 0) {
                tabs[0].classList.add('active');
            }
        });
    </script>
</body>
</html> 